#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=1e5,L=1e6;
int t,n,m,l,vv,d[N+5],v[N+5],a[N+5],p[N+5],nex[L+5],ans1,ans2=1;
struct s{
	int l,r;
}wh[N+5];
bool cmp(s a,s b){
	return a.r<b.r;
}
signed main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	cin>>t;
	for(int i=1;i<=t;i++){
		int num=0;
		ans1=0;
		ans2=0;
		memset(wh,0,sizeof(wh));
		memset(nex,0,sizeof(nex));
		cin>>n>>m>>l>>vv;
		for(int j=1;j<=n;j++){
			cin>>d[j]>>v[j]>>a[j];
		}
		for(int j=1;j<=m;j++){
			cin>>p[j];
			for(int k=p[j-1]+1;k<=p[j];k++){
				nex[k]=j;
			}
		}
		for(int j=1;j<=n;j++){
			if(a[j]==(int)0&&v[j]>vv&&p[m]>=d[j]){
				ans1++;
				num++;
				wh[num].l=nex[d[j]];
				wh[num].r=m;
			}
			int w1=d[j]+(floor)(vv*vv-v[j]*v[j])/a[j]/2;
			if(a[j]>(int)0&&p[m]>w1){
				num++;
				ans1++;	
				wh[num].l=nex[w1];
				wh[num].r=m;
			}
			int w2=d[j]+(int)(ceil)(double(vv*vv-v[j]*v[j])/a[j]/2);
			if(a[j]<(int)0&&p[nex[d[j]]]<w2){
				ans1++;
				num++;
				wh[num].l=nex[d[j]];
				wh[num].r=nex[w2]-1;
			}
		}
		cout<<ans1<<" ";
		sort(wh+1,wh+num+1,cmp);
		int left=-1;
		for(int j=1;j<=num;j++){
			if(wh[j].l>left){
				ans2++;
				left=wh[j].r;
			}
		}
		cout<<m-ans2<<endl;
	}
	return 0;
}
